<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="en">
  <head>
  	<base href="<%=basePath%>">
  	<!-- jsp文件头和头部 -->
  	<%@ include file="../../system/admin/top.jsp"%> 
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>病历列表</title>
    <script src="static/js/jquery-1.11.3.js"></script>
    <script src="static/js/bootstrap.min.js"></script>
    <script src="static/layer/layer.js"></script><!-- 弹出窗 -->
    <script type="text/javascript" src="static/js/bootbox.min.js"></script>
    <style>
    	.table th,
    	.table td {
    		text-align:center;
    		vertical-align:middle;
    	}
    	form {
		    margin: 0;
		    margin-top:10px;
		}
    </style>
</head>
  <body>
    <div class="container-fluid" style="padding-left:0;padding-right:40px;">
    
    <!-- 若是根据患者ID查询的，不显示检索 -->
	<form action="caseOrder/list.do" method="post" name="Form" id="Form">
		<input type="hidden" name="hzId" value="${pd.hzId}"/>
    	<c:if test="${empty pd.hzId }">
    	<!-- 检索  -->
			<table>
				<tr>
					<td>
						<span class="input-icon">
							<input autocomplete="off" id="nav-search-input" type="text" name="name" value="${pd.name}" placeholder="这里输入姓名" />
							<i id="nav-search-icon" class="icon-search"></i>
						</span>
					</td>
					<td>
						<span class="input-icon">
							<input autocomplete="off" id="phone" type="text" name="phone" value="${pd.phone}" placeholder="这里输入电话" />
							<i id="nav-search-icon2" class="icon-search"></i>
						</span>
					</td>
					<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="search();" title="检索"><i id="nav-search-icon" class="icon-search"></i></a></td>
				</tr>
			</table>
			
			<!-- 检索  -->
    	</c:if>
        <table id="table_report" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th class="center">
						<label><input type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
						</th>
						<th>序号</th>
						<!-- <th>病历编号</th> -->
						<th>姓名</th>
						<th>电话</th>
						<th>主诉/现病史</th>
						<!-- <th>诊断</th> -->
						<th>医师姓名</th>
						<th>录入时间</th>
						<th class="center">操作</th>
					</tr>
				</thead>
				<tbody>
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty caseOrderList}">
						<c:forEach items="${caseOrderList}" var="caseOrder" varStatus="vs">
							<tr>
								<td class='center' style="width: 30px;">
									<label><input type='checkbox' disabled="disabled" /><span class="lbl"></span></label>
								</td>
								<td class='center' style="width: 30px;">${vs.index+1}</td>
								<%-- <td>${caseOrder.bldcode }</td> --%>
								<td>${caseOrder.name }</td>
								<td>${caseOrder.phone }</td>
								<td>${caseOrder.xbs }</td>
								<%-- <td>${caseOrder.zd }</td> --%>
								<td>${caseOrder.USERNAME }</td>
								<td>${caseOrder.createdate }</td>
								<td style="width:123px;">
									<a class='btn btn-mini btn-success' title="详情" onclick="detail(${caseOrder.id})">详情</a>	
									<a class='btn btn-mini btn-info' title="处方" href="<%=basePath%>cfOrder/listByCid?caseId=${caseOrder.id}">处方</a>
									<a class='btn btn-mini btn-danger' title="删除" onclick="deleteCaseOrder('${caseOrder.id}')">删除</a>
								</td>
							</tr>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="10" class="center">没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
			</table>
			<div class="page-header position-relative">
				<table style="width:100%;">
					<tr>
						<!-- <td style="vertical-align:top;"><a class="btn btn-small btn-success" onclick="add();">新增</a></td> -->
						<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
					</tr>
				</table>
			</div>
		</form>
    </div>
    <script type="text/javascript">
			$(top.hangge());
			
			//详情
			function detail(bldId){
				top.jzts();	//显示加载进度
				 var diag = new top.Dialog();
				 diag.Drag=true;
				 diag.Title ="新增";
				 diag.URL = '<%=basePath%>caseOrder/findById?id=' + bldId ;
		 		 diag.Width = 1000;
				 diag.Height = 800; 
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('row').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location=self.location",100);
					 }else{
						 nextPage('${page.currentPage}');
					 }
				}
				diag.close();
			 };
			 diag.show();
			}
			
			//删除
		function deleteCaseOrder(_id){
			bootbox.confirm("确定要删除吗?", function(result) {
				if(result) {
					top.jzts();
					var url = "<%=basePath%>caseOrder/deleteOne.do?id="+_id+"&tm="+new Date().getTime();
					$.get(url,function(data){
						if(data.msg=="success"){
						 	layer.alert("删除成功");
						 	//$(top.hangge());
						 	//window.location.reload(true);
						 	nextPage('${page.currentPage}');
						 }else{
						 	layer.alert(data.msg);
						 	//$(top.hangge());
						 	nextPage('${page.currentPage}');
						 	//window.location.reload(true);
						 }
						//nextPage('${page.currentPage}');
					});
					/*$.ajax({
							type: "POST",
							url: "<%=basePath%>caseOrder/deleteOne",
					    	data: {id:_id,tm:new Date().getTime()},
							dataType:'json',
							//beforeSend: validateData,
							cache: false,
							async: false,
							success: function(data){
								layer.alert(${page.currentPage});
								 if(data.msg=="success"){
								 	layer.alert("删除成功");
								 	//$(top.hangge());
								 	//window.location.reload(true);
								 	nextPage('${page.currentPage}');
								 }else{
								 	layer.alert(data.msg);
								 	//$(top.hangge());
								 	nextPage('${page.currentPage}');
								 	//window.location.reload(true);
								 }
							}
						});
					*/
				}
			});
		}
	</script>
  </body>
</html>
